import Vue from 'vue'
import VueRouter from 'vue-router'
import MyLayout from '@/views/MyLayout'

Vue.use(VueRouter)
const MyHouse = () => import('@/views/MyLayout/MyHouse.vue')
const MyInfo = () => import('@/views/MyLayout/MyInfo.vue')
const MyIndex = () => import('@/views/MyLayout/MyIndex.vue')
const MyUser = () => import('@/views/MyLayout/MyUser.vue')
const MyLogin = () => import('@/views/MyLogin.vue')
const MyRegister = () => import('@/views/MyRegister.vue')
const MyAddress = () => import('@/views/MyAddress.vue')
const routes = [
  { path: '/', redirect: '/layout' },
  { path: '/login', component: MyLogin },
  { path: '/address', component: MyAddress },
  { path: '/register', component: MyRegister },
  {
    path: '/layout',
    component: MyLayout,
    redirect: '/index',
    children: [
      { path: '/find', component: MyHouse },
      { path: '/info', component: MyInfo },
      { path: '/index/:label', component: MyIndex },
      { path: '/user', component: MyUser }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
